/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package control;

import java.util.LinkedList;
import java.util.Vector;
import model.Despachante;
import model.Processo;
import model.Processador;

/**
 *
 * @author 
 * Abraão de Santana 
 * Jorge Thiago
 * Leandro C. Arantes
 */
public class DespachanteFCFS implements Despachante {

    private LinkedList<Processo> processQueue;

    public DespachanteFCFS(LinkedList<Processo> processQueue) {
        this.processQueue = processQueue;
    }

    public void activate(Processador processor) {
        for ( int i = 0; i < processQueue.size(); i++ )
        {
            Processo process = processQueue.get(i);
            if ( processor.getMemoria().contemProcesso(process) )
            {
                processor.setProcessoAtivo(process);
                processor.setExecutando(true);
                processQueue.remove(i);

                break;
            }
        }
    }

}
